import $ from 'jquery';
export function sayHello() {
    //头部显示隐藏
    $(".new-nav-page .left-nav-list .left-nav-item,.new-nav-page .nav-right .lyk-hover").hover(function () {
        var e = $(this);
        e.hasClass("ai-nav-item") || (a = setTimeout(function () {
            $(".new-nav-page .left-nav-list .left-nav-item,.new-nav-page .nav-right .lyk-hover").removeClass("hover-css"),
                e.addClass("hover-css"),
                $(".left-nav-mask").remove(),
                (e.parents(".new-nav-page").hasClass("list-scroll-white") || e.parents(".new-nav-page").hasClass("other-scroll-white") || !e.hasClass("more-nav-item")) && $("body").append("<div class='left-nav-mask'></div>")
        }, 200),
            function (t) {
                if (t.hasClass("left-nav-item") && 0 == t.find(".subnav-model-classification").length && !t.hasClass("ai-nav-item")) {
                    t.append('<div class="subnav-model-classification"></div>');
                    var r = ""
                        , e = 462;
                    t.hasClass("d3-nav-item") ? (r = "3d",
                        e = 542) : t.hasClass("su-nav-item") ? (r = "su",
                            e = 476) : t.hasClass("linggan-nav-item") ? (r = "lg_anli",
                                e = 468) : t.hasClass("tietu-nav-item") ? (r = "map_material",
                                    e = 468) : t.hasClass("cad-nav-item") ? (r = "cad",
                                        e = 468) : t.hasClass("vr-nav-item") && (r = "vr",
                                            e = 462),
                        t.find(".subnav-model-classification").css("min-height", e + "px"),
                        "" != r
                }
            }(e),
            0 == $(".new-nav-page .nav-adv-img").length)
    }, function () {
        a && clearTimeout(a),
            a = null,
            setTimeout(function () {
                a || ($(".left-nav-mask").remove(),
                    $(".new-nav-page .left-nav-list .left-nav-item,.new-nav-page .nav-right .lyk-hover").removeClass("hover-css"))
            }, 200)
    })

    //搜索
    $(window).scroll(function () {
        $(".newwww-search-content").hasClass("newwww-search-show") && setTimeout(function () {
            $(".mask-www-input-search").css("display", "none"),
                $(".newwww-search-content").removeClass("newwww-search-show"),
                $(".js-search-normal").blur()
        }, 100)
    })

    $(".js-search-normal").on("focus", function () {
        $(".newww-related-search .lately-search").hide();
        $(this).parents(".newwww-search-content").addClass("newwww-search-show"),
            $(".mask-www-input-search").fadeIn(50),
            $(this).parents(".model-search-position").addClass("newwww-search-show-list"),
            $(this).addClass("newww-related-search-active")

    })

    $(".js_close_btn_search").on("click", function () {
        $(".newwww-search-content").removeClass("newwww-search-show"),
            $(".mask-www-input-search").fadeOut(),
            $(".head-public-search").fadeOut(function () {
                $(this).remove()
            })
    })

    //吸顶
    $(function () {
        var t, e = null, r = 1, n = !0, o = !0, a = $(window).height(), i = $(document).height(), s = $(window).scrollTop(), l = null, c = $(".interest-occupying").offset().top, d = {}, u = $(".www-footer").height() + 1500, p = !1, h = 0, f = Math.floor(2 * Math.random()), v = function () {
            for (var t = Math.floor(6 * Math.random()) + 5, e = [], a = [], i = 0; i < t; i++) {
                var n = Math.floor(15 * Math.random()) + 1;
                -1 == e.indexOf(n) ? e.push(n) : i--
            }
            for (var s = 0; s < t; s++) {
                var r = Math.floor(15 * Math.random()) + 16;
                -1 == a.indexOf(r) ? a.push(r) : s--
            }
            var o = Math.round(7 * t / 10)
                , l = Math.round(3 * t / 10)
                , c = e.slice(0, o)
                , d = a.slice(0, l);
            return c.concat(d)
        }();
        $(window).scroll(function () {
            s = $(this).scrollTop(),
                i = $(document).height(),
                a = $(this).height(),
                c < s ? ($(".news-index-other").css({
                    opacity: 1,
                    visibility: "visible",
                    "z-index": 11
                }),
                    $(".interest-occupying .flex-top-interest").addClass("fixed-interest"),
                    $(".new-nav-page").addClass("other-scroll-white head-fixed")) : ($(".news-index-other").removeAttr("style"),
                        $(".interest-occupying .flex-top-interest").removeClass("fixed-interest"),
                        $(".new-nav-page").removeClass("other-scroll-white head-fixed")),
                0 != $(".list-popup-favorite").length && ($(".list-popup-favorite").fadeOut(function () {
                    $(this).remove()
                }),
                    $(".select-mask-collect").removeClass("select-mask-collect"),
                    $(".model-contrast").find("a,div").removeAttr("style")),
                0 != $(".new-edition-home .show-active").length && $(".show-active").removeClass("show-active"),
                i - u - 500 <= s + a && n && o,
                h < s && 150 <= s && $(".modalOpenWidth").hasClass("is-show") ? $(".modalOpenWidth").addClass("modalOpenShow") : $(".modalOpenWidth").removeClass("modalOpenShow"),
                h = s
        })
    })

    //下拉菜单
    $(document).on("click", ".model-search-position .home-search-category,.interest-content .interest-search-category", function (t) {
        $(this).toggleClass("show-active"),
            $(this).hasClass("home-search-category") ? $(".interest-content .interest-search-category").removeClass("show-active") : $(".model-search-position .home-search-category").removeClass("show-active"),
            $(document).one("click", function () {
                $(".model-search-position .home-search-category,.interest-content .interest-search-category").removeClass("show-active")
            }),
            "li" != t.target.localName && t.stopPropagation()
    })

    //吸顶搜索框
    $(".js-nav-search").on("focus", function () {
        if ($(this).parents(".js-new-search-box").addClass("active").find(".js-new-search-input ").css("background", "#F8F8F8"),
            $(".scroll-white head-fixed .nav-right").addClass("search-active-right"),
            $(".new-nav-page .left-nav-list,.new-nav-page .right-nav-item").hide(),
            $(".new-nav-page .login-nav-item").show(),
            $(".js-new-related-search").show(),
            $(".new-nav-search-mask").fadeIn(),
            0 == s && (setTimeout(function () {
                l()
            }, 100),
                s++),
            $.cookie("www_search_history") && "null" != $.cookie("www_search_history")) {
            var e = JSON.parse($.cookie("www_search_history"));
            0 != e.length && ($(".js-new-related-search .lately-search .related-search-class").empty(),
                e.forEach(function (e) {
                    e && 0 < e.myTrim().length && $(".js-new-related-search .lately-search .related-search-class").append('<a class="lately-wrod" data-text="' + e + '" data-type="' + $(".search-title>span.active").attr("data-id") + '">' + e + "</a>")
                }),
                $(".js-new-related-search .lately-search").show(),
                $(".js-new-related-search .lately-wrod").on("click", function () {
                    N($(this).attr("data-text"), r || o(), 2, 1)
                }),
                $(".lately-search .icon_search_delete").on("click", function () {
                    $.cookie("www_search_history", null, {
                        expires: -1,
                        path: "/",
                        domain: "3d66.com"
                    }),
                        $(".js-new-related-search .lately-search").hide()
                }))
        } else
            $(".js-new-related-search .lately-search").hide();
        r != $(".js-new-search-box .search-title>span.active").attr("data-id") && t(r = $(".js-new-search-box .search-title>span.active").attr("data-id"))
    })

    //吸顶搜索框关闭
    $(document).on("click", ".js-nav-search-close,.new-nav-search-mask", function () {
        $(".js-new-search-box").removeClass("active").find(".js-new-search-input").removeAttr("style"),
            $(".scroll-white head-fixed .nav-right").removeClass("search-active-right"),
            $(".new-nav-page .left-nav-list,.new-nav-page .right-nav-item").show(),
            $(".js-new-related-search").hide(),
            $(".autocomplete-suggestions").hide(),
            $(".js-nav-search").blur(),
            $(".new-nav-search-mask").fadeOut(),
            s = 0;
        var e = $('.js-new-search-box .search-title>span[data-id="' + o() + '"]');
        $(".js-new-search-input .select-class .select-class-txt").text(e.text().trim()),
            e.addClass("active").siblings().removeClass("active"),
            V($(this).parents(".js-new-search-box"), o())
    })
}